<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="mall.demo.mybatis.pojo.Product"%>
<%@ page import="mall.demo.mybatis.pojo.Admin"%>
<%@ page import="mall.demo.mybatis.pojo.User"%>
<%@ page import="mall.demo.mybatis.domain.PageBean"%>
<%@ page import="mall.demo.mybatis.service.ProductService"%>
<%@ page import="mall.demo.mybatis.service.UserService"%>
<%@ page import="mall.demo.util.SessionKeyEnum"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.ArrayList"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>管理员</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/admin.css" rel="stylesheet">
<script src="/scripts/jquery.min.js"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>
</head>
<%
	//先获取会话中的管理员对象
	Object obj = session.getAttribute(SessionKeyEnum.adminObj.name());
	List<User> userList = (new UserService()).getAllUsers();
	boolean isUserLoggedIn = false;
	if (obj != null) {
		isUserLoggedIn = true;
	}

	Admin adminInfo = null;
	if (isUserLoggedIn) {
		adminInfo = (Admin) obj;
	}
	//style="background:url('images/bg2.jpg')"
%>
<body>
	<div class="container">
		<div class="top">
			<div class="top_logo">
				<h2>琳琅商城</h2>
			</div>
			<!-- 分为登录和未登录两种情况 -->
			<div class="top_userInfo">
				<%
					if (isUserLoggedIn) {
				%>
				<b>欢迎：<%=adminInfo.getLoginName()%></b>&nbsp;| <b>你的身份是:管理员</b>&nbsp;|
				<b><a href="logout.do">退出登录</a></b>
				<%
					} else {
				%>
				<b><a href="login.jsp">登录</a></b>
				<%
					}
				%>
			</div>
			<br>
			<hr>
		</div>
		<nav class="navbar navbar-default" role="navigation">
		<div>
			<ul class="nav navbar-nav">
				<li class="active"><a href="admin.jsp">用户管理</a></li>
				<li><a href="admin_order.jsp">订单管理</a></li>
				<li><a href="admin_product.jsp">商品管理</a></li>
				<li><a href="admin_product_add.jsp">添加商品</a></li>
			</ul>
		</div>
		</nav>
		<div class="user_list">
			<table>
				<tr class="table_top">
					<th>用户编码</th>
					<th>用户名称</th>
					<th>用户密码</th>
					<th>用户昵称</th>
					<th>邮箱</th>
					<th>锁定状态</th>
					<th>删除用户</th>
					<th>锁定用户</th>
				</tr>
				<%
					for (User user : userList) {
				%>
				<tr>
					<td><%=user.getUserId()%></td>
					<td><%=user.getLoginName()%></td>
					<td><%=user.getPassword()%></td>
					<td><%=user.getNickname()%></td>
					<td><%=user.getEmail()%></td>
					<td>
						<%
						if(user.getIs_locked() == 0) {
						%>
						绿色用户
						<%
						} else {
						 %>
						 黑名单用户
						 <%
						 }
						  %>
					</td>
					<td><a href="deleteUser.do?userid=<%=user.getUserId()%>">删除用户</a></td>
					<%
					if(user.getIs_locked() == 0) {
					 %>
					<td><a href="lockUser.do?userid=<%=user.getUserId()%>">拉入黑名单</a></td>
					<%
					} else {
					 %>
					<td><a href="unlockUser.do?userid=<%=user.getUserId()%>">移出黑名单</a></td>
					<%
					}
					 %>
				</tr>
				<%
					}
				%>
			</table>
		</div>
	</div>

</body>
</html>
